export default {
  state: {
    name: 'hanxiao'
  },
  mutations: {
    updateName(state, payload) {
      state.name = payload;
    }
  },
  actions: {
    // context只针对本模块
    aUpdateName(context) {
      new Promise((resolve, reject) => {
        setTimeout(() => {
          context.commit('updateName', 'songyuan');
        }, 1000);    
      });
    }
  },
  getters: {
    fullName(state) {
      return state.name + 'beijin';
    },
    fullName2(state, getters) {
      return getters.fullName + 'baijing';
    },
    fullName3(state, getters, rootState) {
      return getters.fullName2 + rootState.counter;
    }
  }
}